{include file="Public/header"}
<style>
    *{
        margin:0;
        padding:0;
    }
    body{
        background: #ffffff;
    }
    .star{
        font-size: 30px;
    }
</style>
<table class="table table-hover">
  <tr>
      <th width="30"></th>
      <th width="120">{:lang('label')['order_id']}</th>
      <th width="120">{:lang('label')['seller']}</th>
      <th width="120">{:lang('label')['phone']}</th>
      <th width="30">{:lang('label')['price']}</th>
      <th width="50">{:lang('label')['status']}</th>
      <th width="50">{:lang('label')['express']}</th>
      <th width="200">{:lang('label')['remark']}</th>
      <th width="100">发单{:lang('label')['time']}
          <div style="float: right;margin-right: 10px;font-size: 13px" onclick="refrush()" title="刷新">
              <!--<span id="number" style="color: red">30</span>-->
              <a id="refrush" style="cursor: pointer" class="am-icon-refresh">刷新</a>
          </div>
      </th>
  </tr>
  {volist name="data" id="order"}
  <tr class="order_tr" id="{$order.order_id}">
      <td style="padding: 0;text-align: center"><span style="color: red;display: none" class="star">⭐</span></td>
      <td style="line-height:30px">{$order.order_id}</td>
      <td style="line-height:30px">{$order.title}</td>
      <td style="line-height:30px">{$order.sellerphone}</td>
      <td style="line-height:30px">￥{$order.last_price}</td>
	  <td style="line-height:40px">{if $order.status == "1"}<span class="text-red">{:lang('label')['order_status_1']}</span>{elseif $order.status != 2 || $order.advance_receive != 0}<span class="text-sub">{:lang('label')['order_status_'.$order.status]}</span>{else}等待商家接单{/if}</td>
      <td style="line-height:30px">{$order.express_name}</td>
      <td style="line-height:30px">{$order.remark}</td>
      <td style="line-height:30px">{$order.time|date="Y-m-d H:i:s",###}</td>
  </tr>
  {/volist}
</table>
{include file="public/pages" /}
<script>
    var last_time = "{$last_time}";

    function update_order() {
        $.post("__URL__/socket?type=dispatch_order&aid={:input('get.aid')}",{},function (newtime) {
            if(newtime > last_time){
                layer.msg('订单列表发生变化！');
                refrush();
            }
        })
    }

    function auto() {
        update_order();
        setTimeout(function () {
            auto();
        },30000);
    }
    auto();

    function refrush() {
        $("#refrush").attr('class','am-icon-refresh am-icon-spin');
        parent.$("#audio").attr('src','/music.mp3');
        parent.document.getElementById('audio').play();
        setTimeout(function () {
            window.location.reload();
        },700)
    }

    $(".order_tr").click(function () {
        parent.order_id = this.id;
        var express_id = parent.express_id;
        parent.$("#iframe").attr("src",'__URL__/dispatch?order_id='+this.id+'&express_id='+express_id);
        $(".order_tr").find('.star').css('display','none');
        $(this).find('.star').css('display','');
    });
</script>
